
package com.ae.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ae.common.annotation.Log;
import com.ae.common.core.controller.BaseController;
import com.ae.common.core.domain.AjaxResult;
import com.ae.common.enums.BusinessType;
import com.ae.system.domain.AiCourse;
import com.ae.system.service.IAiCourseService;
import com.ae.common.utils.poi.ExcelUtil;
import com.ae.common.core.page.TableDataInfo;

/**
 * 课程管理Controller
 * 
 * @author ruoyi
 * @date 2024-04-26
 */
@RestController
@RequestMapping("/system/courseManage")
public class AiCourseController extends BaseController
{
    @Autowired
    private IAiCourseService aiCourseService;

    /**
     * 查询课程管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:courseManage:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiCourse aiCourse)
    {
        startPage();
        List<AiCourse> list = aiCourseService.selectAiCourseList(aiCourse);
        return getDataTable(list);
    }

    /**
     * 导出课程管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:courseManage:export')")
    @Log(title = "课程管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiCourse aiCourse)
    {
        List<AiCourse> list = aiCourseService.selectAiCourseList(aiCourse);
        ExcelUtil<AiCourse> util = new ExcelUtil<AiCourse>(AiCourse.class);
        util.exportExcel(response, list, "课程管理数据");
    }

    /**
     * 获取课程管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:courseManage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiCourseService.selectAiCourseById(id));
    }

    /**
     * 新增课程管理
     */
    @PreAuthorize("@ss.hasPermi('system:courseManage:add')")
    @Log(title = "课程管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiCourse aiCourse)
    {
        return toAjax(aiCourseService.insertAiCourse(aiCourse));
    }

    /**
     * 修改课程管理
     */
    @PreAuthorize("@ss.hasPermi('system:courseManage:edit')")
    @Log(title = "课程管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiCourse aiCourse)
    {
        return toAjax(aiCourseService.updateAiCourse(aiCourse));
    }

    /**
     * 删除课程管理
     */
    @PreAuthorize("@ss.hasPermi('system:courseManage:remove')")
    @Log(title = "课程管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiCourseService.deleteAiCourseByIds(ids));
    }
}
